//
//  ThirdViewController.m
//  UI_Lesson11.homework
//
//  Created by dllo on 15/11/10.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "ThirdViewController.h"
#import "ThirdTwoViewController.h"
@interface ThirdViewController () <ThirdTwoViewControllerDelegate>
@property (nonatomic, retain) UITextField *textField;
@property (nonatomic, retain) UIButton *button;
@end

@implementation ThirdViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.navigationController.navigationBar.barTintColor = [UIColor blackColor];
    self.view.backgroundColor = [UIColor colorWithRed:0.9 green:0.3 blue:0.7 alpha:1];
    
    
    self.button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    _button.frame = CGRectMake(80, 300, 200, 160);
    [_button setTitle:@"开始" forState:UIControlStateNormal];
    [self.view addSubview:_button];
    [_button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    
    self.textField = [[UITextField alloc] initWithFrame:CGRectMake(100, 100, 100, 30)];
    self.textField.borderStyle = UITextBorderStyleRoundedRect;
    [self.view addSubview:_textField];
    [_textField release];

    
    
}
- (void)buttonAction:(UIButton *)button
{
    ThirdTwoViewController *twoVC = [[ThirdTwoViewController alloc] init];
    twoVC.delegate = self;
    twoVC.str = _textField.text;
    
    void(^block)(void) = ^(void){
        self.view.backgroundColor = [UIColor colorWithRed:arc4random() % 256/255.0 green:arc4random() % 256/255.0 blue:arc4random() % 256/255.0 alpha:1];
        
        
    };
    twoVC.block = block;
    
    
    [self.navigationController pushViewController:twoVC animated:YES];
    [twoVC release];
    
    
    
    
}

- (void)passValue:(NSString *)str
{
    _button.titleLabel.text = str;
    
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
